package com.peng.web;

import com.peng.springtest.aop.AspectAnnotation;
import java.util.Objects;
import java.util.Set;
import lombok.Data;
import org.springframework.stereotype.Component;

/**
 * AopTextService
 *
 * @author lupeng10
 * @create 2024-04-15 21:20
 */
@Component
public class AopTextService {

    @Data
    public static class Person {
        private String name;
        private int age;

        public Person(String name, int age) {
            this.name = name;
            this.age = age;
        }

        public Person() {
        }
    }

    enum Type {
        A(1, "A"),
        B(2, "B"),
        ;
        ;
        private final int code;
        private final String name;

        Type(int code, String name) {
            this.code = code;
            this.name = name;
        }

        public int getCode() {
            return this.code;
        }

        public String getName() {
            return this.name;
        }

        public static Type fromCode(int code) {
            for (Type anEnum : Type.values()) {
                if (Objects.equals(anEnum.getCode(), code)) {
                    return anEnum;
                }
            }
            return null;
        }
    }

    @AspectAnnotation
    public Person getPerson(long age, Set<String> labelKeys, Type type) {
        return new Person("aaa", 11);
    }

}
